package com.shisfish.library.Utils;

import javax.servlet.http.HttpServletRequest;

import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;

import com.shisfish.library.Utils.Global.GlobalVariable;

public class CacheUtils extends GlobalVariable {

	public static CacheManager getCacheManger(HttpServletRequest request) {
		CacheManager cachaManager = CacheManager.create(request.getSession()
				.getServletContext().getRealPath("/")
				+ "/ehcache.xml");
		return cachaManager;
	}

	// 根据缓存名称，返回缓存值
	public static Cache getCache(String cacheName, HttpServletRequest request) {

		CacheManager cacheManager = CacheManager.create(request.getSession()
				.getServletContext().getRealPath("/")
				+ CACHE_FILE);
		
		Cache cache = cacheManager.getCache(cacheName);

		return cache;
	}

}
